#!/bin/bash                                                                                                                                                 

res=`mysql ch -u chuser -e 'SELECT FLOOR(UTC_TIMESTAMP()-MAX(time)) FROM NodeState'`
last=`echo $res |cut -d' ' -f2`


if [ $last -gt 3600 ]
then
    sudo service ch-sf stop
    sudo service ch-base stop
    sleep 5
    sudo service ch-sf start
    sudo service ch-base start
fi
